<?php
/**
 * Enter description here...
 * 宝贝url转换成电商中文名
 */


class ml_tool_shop
{
    static public function url2shopcn ($url)
    {
        $arr=ml_factory::load_standard_conf('fetch');
        $shop_arr=$arr['shop_arr'];
        $shop=self::url2shop($url);
        return $shop_arr[$shop]['cn'];
    }
    
    
    static public function url2shoplogo($url){
        $arr=ml_factory::load_standard_conf('fetch');
        $shop_arr=$arr['shop_arr'];
        $shop=self::url2shop($url);
        return $shop_arr[$shop]['ico'];
    }
    
    static public function url2shop($url){
        
        $host=array('com','cn','net','hk','org','cc','mobi','info','so','co');
        $url_arr=parse_url($url);
        $host_arr=explode('.',$url_arr['host']);
        while ($a=array_pop($host_arr)){
            if(!in_array($a,$host)){
                $shop=$a;
                break;
            }
        }
        return self::format_shop($shop);
    }
    
    static public function format_shop($shop){
        switch($shop){
            case 'ing2ing':
            case 'rutisher':
            case 'suorang':
            case 'baoyeah':
            case 'clafield':
            case 'qjherb':
                $shop='moonbasa';
                break;
            case 'shishang71':
                $shop='shishangqiyi';
                break;
            case 'qq':
                $shop='paipai';
                break;
        }
        return $shop;
    }
}